<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:form id="formLOrca">
	<p:panel
		header="#{message.header_lista_orca} - #{message.label_filtro}"
		style="position: relative; left:10%;">
		<h:panelGrid columns="6" style="text-align:left;">

			<h:outputLabel value="#{message.label_emissao_de}" />
			<p:inputMask style="margin-left: 5px;font-size: 13px;" id="dataDe"
				value="#{listaOrcamentoTela.dataDe}" size="6" maxlength="8"
				mask="99/99/99" />

			<h:outputLabel style="margin-left: 30px;"
				value="#{message.label_emissao_ate}" />
			<p:inputMask style="margin-left: 5px;font-size: 13px;" id="dataAte"
				value="#{listaOrcamentoTela.dataAte}" size="6" maxlength="8"
				mask="99/99/99" />

			<h:outputLabel style="margin-left: 30px;"
				value="#{message.label_orcamento}" />
			<p:inputText style="margin-left: 5px;" size="12" id="nOrca"
				value="#{listaOrcamentoTela.numero}" />

			<h:outputLabel value="#{message.label_status}"></h:outputLabel>
			<p:selectOneMenu
				style=" text-align: justify; float:
				left; margin-left:5px;padding-right: 25px;"
				value="#{listaOrcamentoTela.statusFiltro}">
				<f:selectItem itemLabel="Aberto" itemValue="Aberto" />
				<f:selectItem itemLabel="Encerrado" itemValue="Encerrado" />
				<f:selectItem itemLabel="Parcial" itemValue="Parcial" />
			</p:selectOneMenu>

			<p:commandButton value="#{message.botao_filtrar}"
				update="orcas,:messages,@parent"
				action="#{listaOrcamentoTela.filtraOrcamentos}">
			</p:commandButton>
		</h:panelGrid>
	</p:panel>
	<p:outputPanel id="orcas" style="width:950px;">
		<p:dataTable value="#{listaOrcamentoTela.listaOrcamentos}"
			var="orcamento" emptyMessage="#{message.table_empty}"
			style="margin-top:20px; width:950px;" paginator="true" rows="5">

			<p:column style="width:4%">
				<p:rowToggler />
			</p:column>

			<p:column sortBy="#{orcamento.numero}">
				<f:facet name="header">
					<h:outputText value="#{message.label_numero}" />
				</f:facet>
				<h:outputText value="#{orcamento.numero}" />
			</p:column>

			<p:column sortBy="#{orcamento.dataEmissao}">
				<f:facet name="header">
					<h:outputText value="#{message.label_dt_emissao}" />
				</f:facet>
				<h:outputText value="#{orcamento.dataEmissao}">
					<f:convertDateTime pattern="dd/MM/yy" />
				</h:outputText>
			</p:column>

			<p:column sortBy="#{orcamento.dataValidade}">
				<f:facet name="header">
					<h:outputText value="#{message.label_dt_validade}" />
				</f:facet>
				<h:outputText value="#{orcamento.dataValidade}">
					<f:convertDateTime pattern="dd/MM/yy" />
				</h:outputText>
			</p:column>


			<p:column>
				<p:commandButton id="but_carr" icon="ui-icon-cart"
					update=":formOrcaForn" oncomplete="dlgCotacaoFornecedores.show()"
					rendered="#{orcamento.status.equals('Aberto') or orcamento.status.equals('Parcial')}"
					action="#{listaOrcamentoTela.preecheListaCotacaoFornecedor(orcamento)}" />
				<p:tooltip for="but_carr" value="#{message.label_aprovar_lote}" />
			</p:column>


			<p:rowExpansion>

				<p:dataTable value="#{orcamento.itensOrcamento}" var="item"
					emptyMessage="#{message.table_empty}"
					style="margin-left:-400px; margin-top:20px; margin-bottom:10px; width:800px; left: 50%;	position: relative; font-size: 10px;"
					rowKey="#{item.numero}"
					rowStyleClass="#{item.forneceApro != null ? 'linha_verde' : ''}">

					<p:column>
						<f:facet name="header">
							<h:outputText value="#{message.label_codigo}" />
						</f:facet>
						<h:outputText value="#{item.produto.codigo}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="#{message.label_marca}" />
						</f:facet>
						<h:outputText value="#{item.produto.marca}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="#{message.label_descricao}" />
						</f:facet>
						<h:outputText value="#{item.produto.descricao}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="#{message.label_um}" />
						</f:facet>
						<h:outputText value="#{item.produto.unidadeMedida}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="#{message.label_tipo}" />
						</f:facet>
						<h:outputText value="#{item.tipo.descricao}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="#{message.label_quantidade}" />
						</f:facet>
						<h:outputText value="#{item.quantidade}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="#{message.label_valor_uni}" />
						</f:facet>
						<h:outputText value="#{item.valorUnitario}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="#{message.label_valor_total}" />
						</f:facet>
						<h:outputText value="#{item.valorTotal}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="#{message.label_fornecedor}" />
						</f:facet>
						<h:outputText rendered="#{item.valorUnitario != 0}"
							value="#{item.forneceApro.nome}(#{item.forneceApro.contato})" />
						<h:outputText rendered="#{item.valorUnitario == 0}" value="--" />
					</p:column>

					<p:column>
						<p:commandButton id="verCotas" icon="ui-icon-search"
							update=":formACota:cotas"
							action="#{listaOrcamentoTela.preencheListaCotacao(item)}"
							oncomplete="dlgAprovaCota.show();"
							rendered="#{item.valorUnitario == 0 and 'Não'.equals(usuario.bloqueado)}">
						</p:commandButton>
						<p:tooltip for="verCotas" value="#{message.tooltip_ver_cota}" />
					</p:column>

				</p:dataTable>
			</p:rowExpansion>

		</p:dataTable>
	</p:outputPanel>
</h:form>
</html>